
var getEvaluationList = function(callback){
	$.get('list', callback);
};


var refreshGrid = function(){
	getEvaluationList(function(data){
		var evaluationList = cleanUpData(data);
		var grid = getGrid();
		var ds = new kendo.data.DataSource({data:evaluationList})
		grid.setDataSource(ds);
		grid.refresh();				
	})
};


$(function(){
	
	var umpiresViewModel = {};
	
	getEvaluationList(function(data){		
		
		var evaluationList = cleanUpData(data);
		
		//setup grid for data
		var grid = $("#grid").kendoGrid({
	        dataSource: evaluationList,
	        sortable: true,
	        resizable: true,
	        filterable: true,
	        selectable: "single",	///CHJ	
			scrollable: true,	
			filterable: false,			
	        pageable: {
	            refresh: true,
	            pageSizes: true
	        },
	        columns: [ {
	                width: 100,
					field: "umpire.fields.name",	
	                title: "Name"
					//template: "#= umpire.name#"
	            }, {	 
					width: 100,
					field: "competition.fields.name",
					title: "Competition"
					//template: "#= competition.name #"
	            } , {	 
					width: 100,
					field: "date",
					title: "Date"
	            } , {	 
					width: 60,
					field: "session",
					title: "Session"
	            } , {	 
					width: 100,
					field: "assessor.fields.name",
					title: "Assessor"
					//template: "#= assessor.name #"
	            } , {	
					width: 80,            	
					field: "overallGrade",
					title: "Overall"
	            } , {	 
					width: 100,
					field: "presentationGrade",
					title: "Posture"
	            } , {	 
					width: 100,
					field: "netSurroundingCheckGrade",
					title: "Check Net"
	            } , {	 
					width: 120,
					field: "racketInspectionGrade",
					title: "Check Racket"
	            } , {	 
					width: 100,
					field: "coinTossGrade",
					title: "Toss Coin"
	            } , {	 
					width: 100,
					field: "scoreAnnouncementGrade",
					title: "Call Score"
	            } , {	 
					width: 100,
					field: "handSignalGrade",
					title: "Hand Signal"
	            } , {	 
					width: 120,
					field: "serviceLawGrade",
					title: "Service Law"
	            } , {	 
					width: 120,
					field: "behaviourLawGrade",
					title: "Behaviour Law"
	            } , {	 
					width: 120,
					field: "situationControlGrade",
					title: "Situation Control"
	            } , {	 
					width: 100,
					field: "scoresheetGrade",
					title: "Score Sheet"
	            } 				
	        ]
	    });
		
				
		//setup button for toolbar
		/* 
		$('#btn-newUmpire').click(function(e){
			window.location.href = '/umpires/new';
		});
		*/
		
	});
	
});